home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AOL File Library: 2,801 to 2,900
/
aol-file-protocol-4400-2801-to-2900.zip
/
AOLDLs
/
C++ Files Library
/
Direct Blitting in C++
/
Blitting.sit
/
Blitting ƒ
/
CDirectVideo.cp
< prev
next >
Wrap
Text File
|
2014-09-28
|
2KB
|
80 lines
// CDirectVideo.cp, the CDirectVideo class methods
//
// Copyright ⌐ 1995, Macneil Shonle. All rights reserved.
#ifndef __CDIRECTVIDEO__
#include <CDirectVideo.h>
#endif
#ifndef __PIXELTYPES__
#include <PixelTypes.h>
#endif
#ifndef __QDOFFSCREEN__
#include <QDOffscreen.h>
#endif
CDirectVideo::CDirectVideo( GDHandle device, Rect *bounds )
{ mGDevice = device;
PixMapHandle theGDPixMap = (*mGDevice)->gdPMap;
// if no bounds are given, use the whole device
mBounds = (bounds != nil) ? *bounds : (*theGDPixMap)->bounds;
NewCleanCPort( mPort, mBounds );
mBitDepth = BitDepth((*theGDPixMap)->pixelSize);
mAddressingMode = true32b; // for 32-Bit QuickDraw, see Graphic Truffles August 1992,
// "Writing Directly To The Screen"
mRowBytes = RowWidth((*theGDPixMap)->rowBytes & 0x1FFFL);
// set the base address
mBaseAddress = PixelPtr(::GetPixBaseAddr( theGDPixMap )) + mBounds.top * mRowBytes;
if( mBitDepth < kEightBit )
mBaseAddress += mBounds.left / (8 / mBitDepth);
else
mBaseAddress += mBounds.left * (mBitDepth / 8);
BuildQuickRow();
}
CDirectVideo::~CDirectVideo()
{ DestroyQuickRow();
DisposeCleanCPort( mPort );
}
void CDirectVideo::NewCleanCPort( CGrafPtr &theGrafPort, const Rect &theBounds )
{ GrafPtr origPort;
::GetPort( &origPort );
// allocate and init the memory
theGrafPort = new CGrafPort;
::OpenCPort( theGrafPort );
::SetPort( GrafPtr(theGrafPort) );
// init the QuickDraw structure members
Rect zeroBounds = theBounds;
::OffsetRect( &zeroBounds, -zeroBounds.left, -zeroBounds.top );
// init the drawing region
RgnHandle drawRegion = ::NewRgn();
::OpenRgn();
::FrameRect( &zeroBounds );
::CloseRgn( drawRegion );
::CopyRgn( drawRegion, theGrafPort->visRgn );
::CopyRgn( drawRegion, theGrafPort->clipRgn );
::PortSize( zeroBounds.right, zeroBounds.bottom );
::MovePortTo( theBounds.left, theBounds.top );
::SetPort( origPort );
}
void CDirectVideo::DisposeCleanCPort( CGrafPtr &theGrafPort )
{ ::CloseCPort( theGrafPort );
delete theGrafPort;
}